/**
 * private的方法无法被其他类调用
 */
package com.example.demo.day0222;


 class   WithFinals {
    private final void f() {
        System.out.println("WithFianls.f()");
    }

    private void g() {
        System.out.println("WithFianls.g()");
    }
}
    class OverridingPrivate extends WithFinals {
        private final void f() {
            System.out.println("OverridingPrivate.f()");
        }

        private void g() {
            System.out.println("OverridingPrivate.g()");
        }
    }

    class OverridingPrivate2 extends OverridingPrivate {
        public final void f() {
            System.out.println("OverridingPrivate2.f()");
        }

        public void g() {
            System.out.println("OverridingPrivate2.g()");
        }
    }

    class FinalOverridingIllusion {
        public static void main(String[] args) {
             OverridingPrivate2 op2 = new OverridingPrivate2();
             op2.f();
             op2.g();
             OverridingPrivate op = op2;//private方法无法被调用
             WithFinals wf = op2;//private中含有隐式的final，所以用final修饰无意义，但会让编译器不报错
        }
    }


